package cn.hxlc.tie.demo.modular.work.controller;/*
 @author rui
 @date 2021/7/30 --11:13
*/

import cn.hxlc.tie.demo.modular.work.model.param.WorkShopEntityParam;
import cn.hxlc.tie.demo.modular.work.service.WorkShopEntityService;
import cn.hxlc.tie.demo.modular.work.service.WorkShopService;
import cn.hxlc.tie.libs.scanner.annotation.GetResource;
import cn.hxlc.tie.libs.scanner.annotation.PostResource;
import cn.hxlc.tie.libs.scanner.stereotype.ApiResource;
import cn.hxlc.tie.model.web.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "车间子表", path = "/workshop")
public class WorkShopEntityController {
    @Autowired
    private WorkShopService workShopService;
    @Autowired
    private WorkShopEntityService workShopEntityService;


    @PostResource(name = "修改", path = "/update",requiredLogin = false,requiredPermission = false)
    public ResponseData update(@RequestBody WorkShopEntityParam workShopEntityParam) {
        workShopEntityService.update(workShopEntityParam);
        return ResponseData.success(ResponseData.DEFAULT_SUCCESS_CODE, "修改成功", null);
    }

    @GetResource(name = "查询详情", path = "/queryDetail",requiredLogin = false,requiredPermission = false)
    public ResponseData detailOne(@RequestParam Long fid) {
        return ResponseData.success(workShopEntityService.detail(fid));
    }

    @PostResource(name = "删除",path = "/delete",requiredLogin = false,requiredPermission = false)
    public ResponseData deleteOne(@RequestParam Long fid){
        return ResponseData.success(workShopEntityService.deteleOne(fid));
    }
    @PostResource(name="添加",path = "/add")
    public ResponseData add(@RequestBody WorkShopEntityParam workShopEntityParam){
        workShopEntityService.add(workShopEntityParam);
        return ResponseData.success(ResponseData.DEFAULT_SUCCESS_CODE,"添加成功",null);
    }
}
